package com.study.rabbit.subscibe;

import java.util.Map;
import java.util.Map.Entry;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageListener;
import org.springframework.amqp.core.MessageProperties;

public class SubscibeListener implements MessageListener{

	@Override
	public void onMessage(Message message) {
		System.out.println("TestConsumerListener监听收到一条消息....");
		MessageProperties properties = message.getMessageProperties();
		Map<String, Object> headers = properties.getHeaders();
		String body = new String(message.getBody());
		
		System.out.println("message headers:");
		for(Entry<String, Object> entry : headers.entrySet()){
			System.out.println("\theader key="+entry.getValue()+",value="+entry.getValue());
		}
		System.out.println("message body="+body);
		System.out.println("TestConsumerListener消息处理完毕");
		
		
	}

}
